package com.dhcc.DRGsHosp.facade.impl.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.dhcc.DRGsHosp.core.domain.Department;
import com.dhcc.DRGsHosp.facade.dto.DepartmentDTO;

public class DepartmentAssembler {
	
	public static DepartmentDTO  toDTO(Department  department){
		if (department == null) {
			return null;
		}
    	DepartmentDTO result  = new DepartmentDTO();
	    	result.setDepCode (department.getDepCode());
     	    	result.setParDepGroupCode (department.getParDepGroupCode());
     	    	result.setParDepStageCode (department.getParDepStageCode());
     	    	result.setParHospCode (department.getParHospCode());
     	    	result.setDepName (department.getDepName());
     	    	result.setDepType (department.getDepType());
     	    	result.setDepTelephone (department.getDepTelephone());
     	    	result.setDepLeader (department.getDepLeader());
     	    	result.setValidStates (department.getValidStates());
     	    	result.setDepOrder (department.getDepOrder());
     	    	result.setDepHis (department.getDepHis());
     	    	result.setDepBedCnt (department.getDepBedCnt());
     	    	result.setDepDoctorCnt (department.getDepDoctorCnt());
     	    	result.setDepGroupDesc(department.getDepGroupDesc());
     	    	result.setIsOpeDep(department.getIsOpeDep());
     	    	result.setDepHisCode(department.getDepHisCode());
     	    	result.setSpecCode(department.getSpecCode());
     	    	result.setCountDRG(department.getCountDRG());
     	    	result.setHospDesc(department.getHospDesc());
     	    return result;
	 }
	
	public static List<DepartmentDTO>  toDTOs(Collection<Department>  departments){
		if (departments == null) {
			return null;
		}
		List<DepartmentDTO> results = new ArrayList<DepartmentDTO>();
		for (Department each : departments) {
			results.add(toDTO(each));
		}
		return results;
	}
	
	 public static Department  toEntity(DepartmentDTO  departmentDTO){
	 	if (departmentDTO == null) {
			return null;
		}
	 	Department result  = new Department();
         result.setDepCode (departmentDTO.getDepCode());
         result.setParDepGroupCode (departmentDTO.getParDepGroupCode());
         result.setParDepStageCode (departmentDTO.getParDepStageCode());
         result.setParHospCode (departmentDTO.getParHospCode());
         result.setDepName (departmentDTO.getDepName());
         result.setDepType (departmentDTO.getDepType());
         result.setDepTelephone (departmentDTO.getDepTelephone());
         result.setDepLeader (departmentDTO.getDepLeader());
         result.setValidStates (departmentDTO.getValidStates());
         result.setDepOrder (departmentDTO.getDepOrder());
         result.setDepHis (departmentDTO.getDepHis());
         result.setDepBedCnt (departmentDTO.getDepBedCnt());
         result.setDepDoctorCnt (departmentDTO.getDepDoctorCnt());
         result.setDepGroupDesc(departmentDTO.getDepGroupDesc());
         result.setIsOpeDep(departmentDTO.getIsOpeDep());
	     result.setDepHisCode(departmentDTO.getDepHisCode());
	     result.setSpecCode(departmentDTO.getSpecCode());
	     result.setCountDRG(departmentDTO.getCountDRG());
	     result.setHospDesc(departmentDTO.getHospDesc());
 	  	return result;
	 }
	
	public static List<Department> toEntities(Collection<DepartmentDTO> departmentDTOs) {
		if (departmentDTOs == null) {
			return null;
		}
		
		List<Department> results = new ArrayList<Department>();
		for (DepartmentDTO each : departmentDTOs) {
			results.add(toEntity(each));
		}
		return results;
	}
}
